package com.weichat.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.weichat.tool.WeiChatUtil;



@Controller
public class URLController {
	//转让
	@RequestMapping("v1")
	public String Transfer(HttpServletRequest req){
		String code=req.getParameter("code");
		String openId=WeiChatUtil.getOpenId(code);
		req.getSession().setAttribute("openId", openId);
		System.out.println("code=="+code+" ---openId=="+openId);
		//User u=us.selectByWechatId(openId);
		//req.getSession().setAttribute("user", u);
		//String url="/zhou/transfer.html";
		///req.getSession().setAttribute("url", url);
		return "/bsea/index.html";
	}
	@RequestMapping("v2")
	public String toconfig(HttpServletRequest req){
		String code=req.getParameter("code");
		String openId=WeiChatUtil.getOpenId(code);
		req.getSession().setAttribute("openId", openId);
		System.out.println("code=="+code+" ---openId=="+openId);
		//User u=us.selectByWechatId(openId);
		//req.getSession().setAttribute("user", u);
		//String url="/zhou/transfer.html";
		///req.getSession().setAttribute("url", url);
		return "/weichatinit-jwh.html";
	}
	
	
}
